set names utf8mb4;
set foreign_key_checks = 0;
-- ---------------------------
-- Table structure for menu
-- ---------------------------
drop table if exists `menu`;
create table `menu`
(
    `id`      int(11) NOT NULL auto_increment,
    `pattern` varchar(255) default NULL,
    primary key (`id`)
) engine = innodb
  auto_increment = 4
  default charset = utf8;

-- ----------------------------
-- Records of menu
-- ----------------------------
begin;
insert into `menu`
values (1, '/admin/**');
insert into `menu`
values (2, '/user/**');
insert into `menu`
values (3, '/guest/**');
commit;

-- ----------------------------
-- Table structure for menu_role
-- ----------------------------
drop table if exists `menu_role`;
create table `menu_role`
(
    `id`  int(11) NOT NULL AUTO_INCREMENT,
    `mid` int(11) default NULL,
    `rid` int(11) DEFAULT NULL,
    primary key (`id`),
    key `mid` (`mid`),
    key `rid` (`rid`),
    constraint `menu_role_ibfk_1` foreign key (`mid`) references `menu` (`id`),
    constraint `menu_role_ibfk_2` foreign key (`rid`) references `role` (`id`)
) engine = InnoDB
  AUTO_INCREMENT = 5
  default charset = utf8;

-- ----------------------------
-- Records of menu_role
-- ---------------------------
begin;
insert into `menu_role`
values (1, 1, 1);
insert into `menu_role`
values (2, 2, 2);
insert into `menu_role`
values (3, 3, 3);
insert into `menu_role`
values (4, 3, 2);
commit;

-- ----------------------------
-- Table structure for role
-- ---------------------------
drop table if exists `role`;
create table if not exists `role`
(
    `id`     int(11) not NULL auto_increment,
    `name`   varchar(32) default NULL,
    `nameZh` varchar(32) DEFAULT NULL,
    primary key (`id`)
) engine = innodb
  auto_increment = 4
  default charset = utf8;

-- ----------------------------
-- Records of role
-- ----------------------------
begin;
insert into `role`
values (1, 'ROLE_ADMIN', '系统管理员');
insert into `role`
values (2, 'ROLE_USER', '普通用户');
insert into `role`
values (3, 'ROLE_GUEST', '游客');
commit;

-- ----------------------------
-- Table structure for user
-- ----------------------------
drop table if exists `user`;
create table `user`
(
    `id`       int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(32)  DEFAULT NULL,
    `password` varchar(255) DEFAULT NULL,
    `enabled`  tinyint(1)   DEFAULT NULL,
    `locked`   tinyint(1)   default NULL,
    primary key (`id`)
) engine = innodb
  auto_increment = 4
  default charset = utf8;

-- ----------------------------
-- Records of user
-- ---------------------------
begin;
insert into `user`
values (1, 'admin', '{noop}123', 1, 0);
insert into `user`
values (2, 'user', '{noop}123', 1, 0);
insert into `user`
values (3, 'blr', '{noop}123', 1, 0);
commit;

-- ----------------------------
-- Table structure for user_role
-- ---------------------------
CREATE TABLE `user_role`
(
    `id`  int NOT NULL AUTO_INCREMENT,
    `uid` int DEFAULT NULL,
    `rid` int DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `rid` (`uid`),
    KEY `uid` (`rid`),
    constraint `user_role_ibfk_1` FOREIGN KEY (`uid`) references `user` (`id`),
    constraint `user_role_ibfk_2` foreign key (`rid`) references `role` (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 5
  DEFAULT CHARSET = utf8mb3;

-- ----------------------------
-- Records of user_role
-- ---------------------------
begin;
insert into `user_role`
values (1, 1, 1);
insert into `user_role`
values (2, 1, 2);
insert into `user_role`
values (3, 2, 2);
insert into `user_role`
values (4, 3, 3);
commit;
set foreign_key_checks = 1;
